home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 52
/
Amiga Format AFCD52 (Issue 136, May 2000).iso
/
-serious-
/
programming
/
basic
/
mildred
/
mildred.lha
/
lha
/
PixelExplosion.lha
/
2DPixelExplosion.asc
next >
Wrap
Text File
|
1999-01-25
|
4KB
|
116 lines
;Pixel Explosion Mildred Library Example.
;
;Programmed by : Mikkel Loekke, aka. FlameDuck.
;
;Please read the README file.
; __ _
;Modified by Sami Naatanen (25.01.1999)
; Just made it faster and more "realistic"
; Can now do easily 4000 pixels and 060 with 10000 stars is still
; super smooth! In fact 15000 stars runs quite smooth
; (some jerking at the beginning).
WBStartup
NoCli
degrad.q = Pi/180
NEWTYPE .point
x.q
y.q
anglx.q
angly.q
End NEWTYPE
#numpnts=4000 ; Change this for more or less points.
Dim pnt.point (#numpnts)
DEFTYPE.l
MCPU Processor ; Tell Mildred which CPU it should use.
Mc2pCPUmode Processor ; Tell Mildred which CPU it should use for c2p.
MReserveBitmaps 1 ; Tell Mildred that we're going to use 1 chunky bitmap.
MReservec2pWindows 1 ; Tell it we only need one c2p display.
MReserveShapes 1 ; Tell Mildred that we need a shape aswell.
InitPalette 0,256 ; Setup a grayscale palette.
For t.l=0To 255
AGAPalRGB 0,t,t,t,t
Next
.initgraphics
MBitmap 0,320,256 ; This will contain our chunky buffer.
Mc2pWindow 0,320,256 ; Setup structures for c2p conversions.
*pbb.l=AllocMem(320*256,$10002) ; Get some free CHIP memory
If *pbb.l ; and if we succeed
CludgeBitMap 0,320,256,8,*pbb ; make it a planar bitmap.
Else End
EndIf
Dim scrtaglst.TagItem(7) ; All this stuff sets up our
scrtaglst(0)\ti_Tag = #SA_Left ; Taglist for the screen we
scrtaglst(0)\ti_Data = 0 ; want.
scrtaglst(1)\ti_Tag = #SA_Depth
scrtaglst(1)\ti_Data = 8
scrtaglst(2)\ti_Tag = #SA_Width
scrtaglst(2)\ti_Data = 320
scrtaglst(3)\ti_Tag = #SA_Height
scrtaglst(3)\ti_Data = 256
scrtaglst(4)\ti_Tag = #SA_BitMap
scrtaglst(4)\ti_Data = Addr BitMap (0)
scrtaglst(5)\ti_Tag = #SA_ShowTitle
scrtaglst(5)\ti_Data = 0
scrtaglst(6)\ti_Tag = #SA_Draggable
scrtaglst(6)\ti_Data = 0
scrtaglst(7)\ti_Tag = #TAG_END ; The most important tag of them all.
ScreenTags 0,"MildredDEMO",&scrtaglst(0) ; Open our intuition screen.
ShowPalette 0 ; Attach our palette to the screen.
Dim cin.q(359),kos.q(359)
For t.l=0 To 359
cin(t)=Sin(degrad*t)
kos(t)=Cos(degrad*t)
Next t
.goagain ; A Label that tells us where to go
; to reset all our variables
For t.l=0To #numpnts
pnt(t)\x=160
pnt(t)\y=128
r.w=Rnd(359)
v.q=Rnd(Rnd(4.4)+3)+Rnd(1.6)
pnt(t)\anglx=cin(r)*v
pnt(t)\angly=kos(r)*v
Next
phase.w=0
Repeat ; Repeat our mainloop ....
Mc2p *pbb ; Convert our chunky buffer to
; our planar bitmap.
MCls ; Clear our chunky buffer
pntskip.w=0
For t=0 To #numpnts ; Boring math part. It's really
; not as complicated as it looks
If (pnt(t)\y>0 AND pnt(t)\y<256) AND (pnt(t)\x>0 AND pnt(t)\x<320)
MPlot pnt(t)\x,pnt(t)\y,255-phase
pnt(t)\x-pnt(t)\anglx
pnt(t)\y-pnt(t)\angly
Else
pntskip+1
EndIf
Next
phase+2:If phase=256 Then pntskip=#numpnts
Until RawStatus($45) OR pntskip=#numpnts ; .... Until we press Escape, or the fade is complete.
If pntskip=#numpnts Then Goto goagain ; If the fade completed, reset variables, and go again.
End ; End our nice program.